local sk__tuwei = fk.CreateSkill {

  name = "sk__tuwei",

  tags = {  },

}



sk__tuwei:addEffect(fk.CardUseFinished, {
  name = "sk__tuwei",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__tuwei.name) and data.card.trueName == "slash" and not player:isNude() then
      if target == player then
        return true
      else
        return table.contains(data.tos, player)
      end
    end
  end,
  on_cost = function (self,event, target, player, data)
    local cards = player.room:askForDiscard(player, 1, 1, true, sk__tuwei.name, true, ".", "#sk__tuwei-invoke", true)
    if #cards > 0 then
      event:setCostData(self, cards)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self), sk__tuwei.name, player, player)
    if player.dead then return end
    if target == player then
      room:doIndicate(player.id, data.tos)
      for _, to in ipairs(data.tos) do
        if player.dead then return end
        if not to.dead and not to:isNude() then
          local cards = room:askForCardsChosen(player, to, 1, 2, "he", sk__tuwei.name, "#sk__tuwei-discard::"..to.id)
          room:throwCard(cards, sk__tuwei.name, to, player)
        end
      end
    else
      if not target.dead and not target:isNude() then
        room:doIndicate(player.id, {target.id})
        local cards = room:askForCardsChosen(player, target, 1, 2, "he", sk__tuwei.name, "#sk__tuwei-discard::"..target.id)
        room:throwCard(cards, sk__tuwei.name, target, player)
      end
    end
  end,
})

return sk__tuwei